2.1 - Predefined methods


What are those predefined methods?

Predefined methods like seen below are methods already included in RedLoader mod template which we will actually use to make our first mod.


protected override void OnInitializeMod()
{
    // Do your early mod initialization which doesn't involve game or sdk references here
    Config.Init();
}

protected override void OnSdkInitialized()
{
    // Do your mod initialization which involves game or sdk references here
    // This is for stuff like UI creation, event registration etc.
    ModExampleUi.Create();
}

protected override void OnGameStart()
{
    // This is called once the player spawns in the world and gains control.
}    
            

OnInitializeMod method

This method gets executed right after starting the game, before it loads into the main menu, and so probably during the RedLoader splashscreen. If you played with mods before, you may know almost every mod comes with a .cfg file located in the Userdata folder with which you can set different options/settings for the mod. The OnInitializeMod method we're talking about here, it's usually used to manage these config files for the mod (known as .cfg files).

OnSdkInitialized method

This method gets executed after the OnInitializeMod method and right before loading into the main menu. Stuff that needs to get executed only once and doesn't really involve gameplay should be done in here. Examples are the creation of an UI using SUI, or registering custom sounds.

OnGameStart method

This method gets executed right before we finished loading into a savegame and we gain player control. Since at this point we are basically loaded into the game, here we can do stuff with the player and world. Note that this method get executed whenever we load into a savegame, so exiting to main menu and loading into the same or another savegame will trigger it again unlike the two methods above which are executed only once. This will also be the method we'll use to make our first mod.